package com.xn.app.muying.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.util.BaseActivity;

/**
 * 体温监测设置页面
 * Created by gaoge on 2017/2/9.
 */
public class TemperatureSetActivity extends BaseActivity implements View.OnClickListener {
    //标题
    private TextView title_name = null;
    //返回键
    private ImageView img_back = null;
    //看护日记
    private RelativeLayout the_log = null;
    //我的设备
    private RelativeLayout equipment = null;
    //报警温度
    private RelativeLayout temperature = null;
    //通知类型
    private RelativeLayout type = null;
    //常见问题
    private RelativeLayout question = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //加载布局
        setContentView(R.layout.temperature_set_activity);
        //初始化
        init();
    }

    //初始化组件
    private void init() {
        title_name = (TextView) findViewById(R.id.title_name);
        img_back = (ImageView) findViewById(R.id.img_back);
        the_log = (RelativeLayout) findViewById(R.id.the_log);
        equipment = (RelativeLayout) findViewById(R.id.equipment);
        temperature = (RelativeLayout) findViewById(R.id.temperature);
        type = (RelativeLayout) findViewById(R.id.type);
        question = (RelativeLayout) findViewById(R.id.question);
        title_name.setText("设置");
        img_back.setOnClickListener(this);
        the_log.setOnClickListener(this);
        equipment.setOnClickListener(this);
        temperature.setOnClickListener(this);
        type.setOnClickListener(this);
        question.setOnClickListener(this);
    }

    /**
     * 单击事件
     *
     * @param view 控件
     */
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            //返回键点击事件
            case R.id.img_back:
                Intent intent = new Intent(TemperatureSetActivity.this, TemperatureMonitoringActivity.class);
                startActivity(intent);
                finish();
                break;
            //看护日记点击事件
            case R.id.the_log:
                startActivity(new Intent(TemperatureSetActivity.this, TemperatureDiaryActivity.class));
                break;
            //我的设备点击事件
            case R.id.equipment:
                startActivity(new Intent(TemperatureSetActivity.this, TemperatureDevicesActivity.class).putExtra("type", 1));
                break;
            //报警温度点击事件
            case R.id.temperature:
                startActivity(new Intent(TemperatureSetActivity.this, TemperatureSettingActivity.class).putExtra("type", 1));
                break;
            //通知类型点击事件
            case R.id.type:
                startActivity(new Intent(TemperatureSetActivity.this, TemperatureMusicActivity.class));
                break;
            //常见问题点击事件
            case R.id.question:
                startActivity(new Intent(TemperatureSetActivity.this, TemperatureQuestionActivity.class));
                break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Intent intent = new Intent(TemperatureSetActivity.this, TemperatureMonitoringActivity.class);
            startActivity(intent);
            finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
